package com.ruoyi.project.king.style.controller;

import java.util.List;

import com.ruoyi.project.king.style.domain.TStyle;
import com.ruoyi.project.king.style.service.ITStyleService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 产品风格Controller
 * 
 * @author ruoyi
 * @date 2020-05-19
 */
@Controller
@RequestMapping("/product/style")
public class TStyleController extends BaseController
{
    private String prefix = "/cms/product/style";

    @Autowired
    private ITStyleService tStyleService;


    @GetMapping()
    public String style()
    {
        return prefix + "/style";
    }

    /**
     * 查询产品风格列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TStyle tStyle)
    {
        startPage();
        List<TStyle> list = tStyleService.selectTStyleList(tStyle);
        return getDataTable(list);
    }

    /**
     * 导出产品风格列表
     */


    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TStyle tStyle)
    {
        List<TStyle> list = tStyleService.selectTStyleList(tStyle);
        ExcelUtil<TStyle> util = new ExcelUtil<TStyle>(TStyle.class);
        return util.exportExcel(list, "style");
    }

    /**
     * 新增产品风格
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存产品风格
     */


    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TStyle tStyle)
    {
        return toAjax(tStyleService.insertTStyle(tStyle));
    }

    /**
     * 修改产品风格
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TStyle tStyle = tStyleService.selectTStyleById(id);
        mmap.put("tStyle", tStyle);
        return prefix + "/edit";
    }

    /**
     * 修改保存产品风格
     */


    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TStyle tStyle)
    {
        return toAjax(tStyleService.updateTStyle(tStyle));
    }

    /**
     * 删除产品风格
     */


    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tStyleService.deleteTStyleByIds(ids));
    }
}
